exports.uploadLocation = (req,res) => {

    var resultData = [];

    //获取合作单位信息
    function searchLocation(cb){

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.commonLocation.Request_Api_Url + "/skip/0/limit/9999",
                method : 'POST',
                data   : {
                    fields : "l_id,l_fid,l_name"
                }
            },
            function (data) {

                resultData = data.result;
                
                var staticFile_1 = "./staticData/locationData.json";
                var staticFile_2 = "./staticData/locationKeyValue.json";

                //省市区ID转化名称数组
                var locationKeyValue = {};
                for(var i=0;i<resultData.data.length;i++){
                    locationKeyValue[resultData.data[i].l_id] = resultData.data[i].l_name;
                }

                var jsonStr_1 = JSON.stringify( resultData );
                var jsonStr_2 = JSON.stringify( locationKeyValue );

                var fs = require('fs');

                fs.writeFile(staticFile_1,jsonStr_1, function(err) {

                    if (err) {
                        return RES.errorResponse(res,"静态省市区信息获取失败");
                    }

                    fs.writeFile(staticFile_2,jsonStr_2,function(err) {

                        if (err) {
                            return RES.errorResponse(res,"静态省市区ID对名称获取失败");
                        }

                        cb();

                    })
    
                });
                
            }
        )

    }


    F.Serial([searchLocation],() => {
        RES.successResponse(res);
    })
}